package com.xc.hotelmgr.webapi.modules.ht.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.Query;

import com.xc.hotelmgr.webapi.modules.ht.dao.HtLogicRoomDao;
import com.xc.hotelmgr.webapi.modules.ht.entity.HtLogicRoomEntity;
import com.xc.hotelmgr.webapi.modules.ht.service.HtLogicRoomService;


@Service("htLogicRoomService")
public class HtLogicRoomServiceImpl extends ServiceImpl<HtLogicRoomDao, HtLogicRoomEntity> implements HtLogicRoomService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Object hotelCode = params.get("hotelCode");
        Object roomCode = params.get("roomCode");
        IPage<HtLogicRoomEntity> page = this.page(
                new Query<HtLogicRoomEntity>().getPage(params),
                new QueryWrapper<HtLogicRoomEntity>().eq(hotelCode != null,"hotel_code",hotelCode)
                        .eq(roomCode != null,"room_code",roomCode)
                        .and(wrapper -> wrapper.eq("status", 0).or().eq("status", 1))
        );

        return new PageUtils(page);
    }

    @Override
    public List<HtLogicRoomEntity> getByHotelId(Long hotelId) {
        return baseMapper.getByHotelId(hotelId);
    }

}